package socket

import (
	"fmt"
	"github.com/gogf/gf/v2/util/gconv"
)

const (
	Ping   uint32 = 0
	Listen uint32 = 10003
	Logout uint32 = 10004
)

func ProcessingData(client *Client, data []byte) {
	defer func() {
		if r := recover(); r != nil {
			fmt.Println("处理数据", r)
		}
	}()
	msg := &Message{}
	err := gconv.Struct(data, msg)
	if err != nil {
		fmt.Println("数据解析失败:", err)
		return
	}
	switch msg.Type {
	case Ping:
		PingController(client)
		break
	case Listen:
		MessageController(msg)
		break
	case Logout:
		LogoutController(msg)
		break
	}

}
